package com.file.system.service.impl.system;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.file.system.entity.system.WebMenu;
import com.file.system.mapper.system.ShiroMapper;
import com.file.system.mapper.system.WebMenuMapper;
import com.file.system.service.system.ShiroService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 菜单 服务实现类
 *
 * @author 田春波
 * @since 2020-05-28
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class ShiroServiceImpl implements ShiroService {

    @Autowired
    private WebMenuMapper mapper;

    @Autowired
    private ShiroMapper shiroMapper;

    //查询菜单
    public List<WebMenu> list(@Param("ew") QueryWrapper<WebMenu> query) {
        return mapper.select(query);
    }

    //查询用户所有权限
    public List<WebMenu> getUserAuth(@Param("userId") Long id) {
        return shiroMapper.selectUserAuth(id);
    }

    //查询用户所有角色id
    public List<Long> getUserRoleIds(@Param("userId") Long id) {
        return shiroMapper.selectUserRoleIds(id);
    }
}
